import parole
from parole.colornames import colors
from parole.display import interpolateRGB
import pygame, random

import sim, main
from util import *
from dungeon import makeFloor, Room, TemplateRoom
import dungeon

# object generators for the inn
floorGenerator = parole.map.MapObjectGenerator("floorGenerator", 
        lambda: sim.Floor('sawdust-covered floor', 10, parole.map.AsciiTile('.',
            colors['Gray'], bg_rgb=colors['DarkKhaki'])), clearFirst=True)
wallGenerator = parole.map.MapObjectGenerator("wallGenerator", 
        lambda: sim.Obj('wooden wall', 100, parole.map.AsciiTile('#',
            colors['Sienna'], bg_rgb=colors['Sienna']), blockLOS=True,
            blockMove=True), clearFirst=True)
doorGenerator = parole.map.MapObjectGenerator("doorGenerator", 
        lambda: sim.Door('door', 100, parole.map.AsciiTile('/',
            colors['White'], bg_rgb=None), parole.map.AsciiTile('+',
                colors['White'])))
stairsUpGenerator = parole.map.MapObjectGenerator("stairsDownGenerator", 
        lambda: sim.Obj('inaccessible stairway leading up', 100,
            parole.map.AsciiTile('<', colors['White'],
                bg_rgb=None), startsVowel=True))
tapGenerator = parole.map.MapObjectGenerator("tapGenerator", 
        lambda: sim.Obj('draft beer tap', 100, parole.map.AsciiTile('&',
            colors['Silver'], bg_rgb=colors['SaddleBrown']),
            blockMove=True), clearFirst=True)
barGenerator = parole.map.MapObjectGenerator("barGenerator", 
        lambda: sim.Obj('varnished oak bar', 100, parole.map.AsciiTile('=',
            colors['SaddleBrown'], bg_rgb=colors['SaddleBrown']),
            blockMove=True), clearFirst=True)
tableGenerator = parole.map.MapObjectGenerator("tableGenerator", 
        lambda: sim.Obj('pine table', 100, parole.map.AsciiTile('O',
            colors['SaddleBrown'], bg_rgb=None), blockMove=True))
chairGenerator = parole.map.MapObjectGenerator("chairGenerator", 
        lambda: sim.Obj('pine chair', 100, parole.map.AsciiTile('h',
            colors['SaddleBrown'], bg_rgb=None)))
windowGenerator = parole.map.MapObjectGenerator("windowGenerator", 
        lambda: sim.Obj('glass window', 100, parole.map.AsciiTile(' ',
            colors['PaleTurquoise'], bg_rgb=colors['PaleTurquoise']),
            blockLOS=False, blockMove=True), clearFirst=True)
        #drunkGenerator = parole.map.MapObjectGenerator("", 
        #        lambda: sim.Obj('fitfully sleeping drunk', 100,
        #            parole.map.AsciiTile('@', colors['DarkBlue']), blockLOS=False,
        #            blockMove=True), clearFirst=False)

template = \
"""
####-###-###+##
#     k       #
#====&====    -
# d h h h     #
+      h      +
# h   hoh   p #
-roh   h   poh-
# r         h #
##-##-#+#-##-##
"""[1:]

legend = {
     '#': wallGenerator,
     '+': doorGenerator,
     '<': stairsUpGenerator,
     '=': barGenerator,
     '&': tapGenerator,
     'o': tableGenerator,
     'h': chairGenerator,
     '-': windowGenerator,
     'd': (dungeon.thingGenerator('npcs', 'drunkard'), chairGenerator),
     'r': (dungeon.thingGenerator('npcs', 'retiredminer'), chairGenerator),
     'k': dungeon.thingGenerator('npcs', 'innkeeper'),
     'p': (dungeon.thingGenerator('npcs', 'peasant'), chairGenerator),
     '.': None,
}

floorColor1 = colors['Olive']
floorColor2 = colors['DarkGreen']
floorName = None
mixture = 0.3

diggable = None # means perimeter

class Inn(TemplateRoom):
    def __init__(self, pos):
        TemplateRoom.__init__(self, template, legend, diggable, pos,
                floorColor1, floorColor2, mixture, floorName)
        self.templateGen.backgroundGen = floorGenerator


roomClass = Inn




